<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="/common/taglibs.jsp" %>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>公司文档</title>
    <%@ include file="/common/util.jsp" %>


    <script type="text/javascript">
        $(document).ready(function () {
            for (var i = 1; i < 12; i++) {
                $("#id" + i).removeClass("current");
            }
            $("#id7").addClass("current");
            $("#showNodata").delay(3000).hide(0);

        });

        function checkFile() {
            var fileName = $("#uploadfile").val();
            var companycode = ${companycode};
            if ($.trim(fileName) == "") {
                dialog_alert("文件名不能为空！");
                return;
            }
            console.log(fileName);
            //判断文件名是否已经存在
            $.ajax({
                url: "/documents/checkFileName.shtml",
                data: {
                    fileName: fileName,
                    companycode: companycode
                },
                dataType: "json",
                success: function (data) {
                    if (data.existFlag == true) {
                        dialog_alert("文件名已经存在！");
                    } else {
                        $("#uploadform").submit();
                    }
                },
                error: function () {
                    dialog_alert("文件上传失败！");
                }
            });
        }

    </script>
</head>
<body class="main">
<div class="-frame -style -luster" id="css_container">
    <!--首页框架页眉部分↓-->
    <%@ include file="/WEB-INF/pages/inc/header.jsp" %>
    <!--首页框架页眉部分↑-->

    <div class="content">
        <!-- Left导航菜单◎开始 -->
        <%@ include file="/WEB-INF/pages/inc/leftmenu.jsp" %>
        <!-- Left导航菜单◎结束 -->

        <div class="main-mid">
            <div class="pos"><img src="${cdnctx}/src/index/img/index.png">
                <a href="<%--${cdnctx}/system/systemMenu.shtml--%>">系统管理</a>
                ><a href="${cdnctx}/system/customerinfo/customerMain.shtml">公司信息管理</a>
                ><a>${customername}_相关文档</a>
            </div>
            <div class="css_contentDiv">
                <div class="searchDetailed  c-border-radius  b-box-shadow">
                    <div id="showNodata">
                        <font color="red">${msg}&nbsp;</font>
                    </div>
                    <c:if test="${roleid == 0}">
                        <form id="uploadform" action="${cdnctx}/documents/upLoadDocuments.shtml" method="post"
                              enctype="multipart/form-data">
                            <div style="padding-left: 15px;">
                                <table>
                                    <tr>
                                        <td width="100px;">
                                            <lable class="search_text">上传文件名称：</lable>
                                        </td>
                                        <td width="180px;"><input id="uploadfile" type="file" name="uploadfile"
                                                                  class="search_input"/>
                                            <input type="hidden" name="companycode" value="${companycode}"/>
                                        </td>
                                        <td width="200px;"><input type="button" value="上&nbsp;传" class="search_btn"
                                                                  onclick="checkFile();"/></td>
                                    </tr>
                                </table>
                            </div>
                        </form>
                        <br/>
                    </c:if>
                    <div class="divTable">
                        <div style="height:99%;background-color:white;overflow: auto;">
                            <table width="100%" class="list_table">
                                <thead>
                                <tr>
                                    <td width="5%">No.</td>
                                    <td>文件名称<span style="color: red;font-size: 14px; ">(点击链接下载)</span></td>
                                </tr>
                                </thead>
                                <c:if test="${not empty(list) }">
                                    <c:forEach items="${list}" var="entity" varStatus="status">
                                        <tr>
                                            <td>${status.index + 1}</td>
                                            <td>
                                                <a href="${cdnctx}/documents/downLoadDocuments.shtml?filename=${entity.fileName}&companycode=${companycode}">${entity.fileName}</a>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                </c:if>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

    <!--首页框架页尾部分↓-->
    <%@ include file="/WEB-INF/pages/inc/footer.jsp" %>
    <!--首页框架页尾部分↑-->
</div>
</body>
</html>
